(define (up lst)
    (up-aux `() lst)
)

(define (up-aux lst1 lst2)
    (cond 
        ((null? lst2) lst1)
        ((list? (car lst2)) 
            (up-aux 
                (append lst1 (car lst2))
                (cdr lst2)
            )
        )
        (else 
            (up-aux 
                (append lst1 (list (car lst2)))
                (cdr lst2)
            )
        )
    )
)

(display 
    (up `((1 2) (3 4)))
)

(display 
    (up `((x (y)) z))
)
